<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>淘贝商城 - 商品分类</title>
    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.4.1/css/bootstrap.min.css">
    <style>
        .navbar-default {
            background-color: #FFA500; /* 橙黄色 */
            border-color: #E69500;
        }
        .navbar-default .navbar-brand,
        .navbar-default .navbar-nav > li > a {
            color: #FFF; /* 白色文字 */
        }
        .navbar-default .navbar-nav > .active > a,
        .navbar-default .navbar-nav > .active > a:hover,
        .navbar-default .navbar-nav > .active > a:focus {
            background-color: #E69500; /* 深一点的橙黄色 */
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <div class="navbar-header">
                <a class="navbar-brand" href="#">淘贝商城</a>
            </div>
        </div>
    </nav>

    <div class="container">
        <h1>商品分类</h1>
        <ul class="nav nav-tabs">
            <li class="active"><a href="#electronics" data-toggle="tab">电子用品</a></li>
            <li><a href="#food" data-toggle="tab">食品</a></li>
            <li><a href="#cosmetics" data-toggle="tab">化妆品</a></li>
            <li><a href="#cars" data-toggle="tab">汽车</a></li>
        </ul>

        <div class="tab-content">
            <div class="tab-pane active" id="electronics">
                <div class="row">
                    <div class="col-md-4">
                        <div class="thumbnail">
                            <img src=D:\taobei-prj\taobei-dev\imgs\10.png alt="口袋音乐键盘">
                            <div class="caption">
                                <h3>口袋音乐键盘</h3>
                                <p>官方EASYPLAY口袋音乐键盘钢琴光遇琴电子琴入门midi儿童玩具乐器</p>
                                <p>价格:520</p>
                                <p>
                                    <button class="btn btn-default add-to-cart" data-name="口袋音乐键盘" data-price="520" data-image=D:\taobei-prj\taobei-dev\imgs\10.png>加入购物车</button>
                                    <button class="btn btn-default add-to-favorites" data-name="口袋音乐键盘" data-price="520" data-image=D:\taobei-prj\taobei-dev\imgs\10.png>收藏</button>
                                </p>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="thumbnail">
                            <img src=D:\taobei-prj\taobei-dev\imgs\11.png alt="宠物专用耳温仪">
                            <div class="caption">
                                <h3>宠物专用耳温仪</h3>
                                <p>猫咪体温计宠物专用测体温狗用兽用猪用电子测量温度计猫用耳温枪</p>
                                <p>价格:29.8</p>
                                <p>
                                    <button class="btn btn-default add-to-cart" data-name="宠物专用耳温仪" data-price="29.8" data-image=D:\taobei-prj\taobei-dev\imgs\11.png>加入购物车</button>
                                    <button class="btn btn-default add-to-favorites" data-name="宠物专用耳温仪" data-price="29.8" data-image=D:\taobei-prj\taobei-dev\imgs\11.png>收藏</button>
                                </p>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="thumbnail">
                            <img src=D:\taobei-prj\taobei-dev\imgs\12.png alt="小米米家电热毯">
                            <div class="caption">
                                <h3>小米米家电热毯</h3>
                                <p>即品已接入米家APP可选智能电热毯单双人电褥子家用石墨烯正品</p>
                                <p>价格:59</p>
                                <p>
                                    <button class="btn btn-default add-to-cart" data-name="小米米家电热毯" data-price="59" data-image=D:\taobei-prj\taobei-dev\imgs\12.png>加入购物车</button>
                                    <button class="btn btn-default add-to-favorites" data-name="小米米家电热毯" data-price="59" data-image=D:\taobei-prj\taobei-dev\imgs\12.png>收藏</button>
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="tab-pane" id="food">
                <div class="row">
                    <div class="thumbnail">
                        <img src=D:\taobei-prj\taobei-dev\imgs\13.png alt="好利来">
                        <div class="caption">
                            <h3>好利来</h3>
                            <p>好利来半熟芝士奥巧奶酪乳酪蛋糕零食糕点健康面包早餐食品下午茶</p>
                            <p>价格:78</p>
                            <p>
                                <button class="btn btn-default add-to-cart" data-name="好利来" data-price="78" data-image=D:\taobei-prj\taobei-dev\imgs\13.png>加入购物车</button>
                                <button class="btn btn-default add-to-favorites" data-name="好利来" data-price="78" data-image=D:\taobei-prj\taobei-dev\imgs\13.png>收藏</button>
                            </p>
                        </div>
                    </div>
                    <div class="thumbnail">
                        <img src=D:\taobei-prj\taobei-dev\imgs\14.png alt="火鸡面">
                        <div class="caption">
                            <h3>火鸡面</h3>
                            <p>【奶油火鸡面】三养韩国进口火鸡面方便面芝士泡面拌面夜宵速食</p>
                            <p>价格:39.9</p>
                            <p>
                                <button class="btn btn-default add-to-cart" data-name="火鸡面" data-price="39.9" data-image=D:\taobei-prj\taobei-dev\imgs\14.png>加入购物车</button>
                                <button class="btn btn-default add-to-favorites" data-name="火鸡面" data-price="39.9" data-image=D:\taobei-prj\taobei-dev\imgs\14.png>收藏</button>
                            </p>
                        </div>
                    </div>
                    <div class="thumbnail">
                        <img src=D:\taobei-prj\taobei-dev\imgs\15.png alt="冰红茶">
                        <div class="caption">
                            <h3>冰红茶</h3>
                            <p>康师傅饮料250ml*24盒纸盒混合冰红茶绿茶茉莉蜜茶水蜜桃酸梅汤</p>
                            <p>价格:27.8</p>
                            <p>
                                <button class="btn btn-default add-to-cart" data-name="冰红茶" data-price="27.8" data-image=D:\taobei-prj\taobei-dev\imgs\15.png>加入购物车</button>
                                <button class="btn btn-default add-to-favorites" data-name="冰红茶" data-price="27.8" data-image=D:\taobei-prj\taobei-dev\imgs\15.png>收藏</button>
                            </p>
                        </div>
                    </div> 
                </div>
            </div>
            <div class="tab-pane" id="cosmetics">
                <div class="row">
                    <div class="thumbnail">
                        <img src=D:\taobei-prj\taobei-dev\imgs\16.png alt="水乳">
                        <div class="caption">
                            <h3>水乳</h3>
                            <p>半亩花田烟酰胺美白水乳套装护肤化妆品淡斑提亮肤色官方正品</p>
                            <p>价格:159.9</p>
                            <p>
                                <button class="btn btn-default add-to-cart" data-name="水乳" data-price="159.9" data-image=D:\taobei-prj\taobei-dev\imgs\16.png>加入购物车</button>
                                <button class="btn btn-default add-to-favorites" data-name="水乳" data-price="159.9" data-image=D:\taobei-prj\taobei-dev\imgs\16.png>收藏</button>
                            </p>
                        </div>
                    </div>
                    <div class="thumbnail">
                        <img src=D:\taobei-prj\taobei-dev\imgs\17.png alt="卸妆膏">
                        <div class="caption">
                            <h3>卸妆膏</h3>
                            <p>新版至本舒颜修护卸妆膏 温和洁净清爽舒适易乳化冲洗保湿洁颜膏</p>
                            <p>价格:52</p>
                            <p>
                                <button class="btn btn-default add-to-cart" data-name="卸妆膏" data-price="52" data-image=D:\taobei-prj\taobei-dev\imgs\17.png>加入购物车</button>
                                <button class="btn btn-default add-to-favorites" data-name="卸妆膏" data-price="52" data-image=D:\taobei-prj\taobei-dev\imgs\17.png>收藏</button>
                            </p>
                        </div>
                    </div>
                    <div class="thumbnail">
                        <img src=D:\taobei-prj\taobei-dev\imgs\18.png alt="卸妆油">
                        <div class="caption">
                            <h3>卸妆油</h3>
                            <p>【抢先加购】艾天然卸妆油全新第三代0压气垫油卸养新升级</p>
                            <p>价格:129</p>
                            <p>
                                <button class="btn btn-default add-to-cart" data-name="卸妆油" data-price="129" data-image=D:\taobei-prj\taobei-dev\imgs\18.png>加入购物车</button>
                                <button class="btn btn-default add-to-favorites" data-name="卸妆油" data-price="129" data-image=D:\taobei-prj\taobei-dev\imgs\18.png>收藏</button>
                            </p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="tab-pane" id="cars">
                <div class="row">
                    <div class="thumbnail">
                        <img src=D:\taobei-prj\taobei-dev\imgs\19.png alt="遮阳膜">
                        <div class="caption">
                            <h3>遮阳膜</h3>
                            <p>汽车遮阳前挡防晒隔热遮阳挡板遮光帘档车内挡风玻璃小车罩遮阳伞</p>
                            <p>价格:9.8</p>
                            <p>
                                <button class="btn btn-default add-to-cart" data-name="遮阳膜" data-price="9.8" data-image=D:\taobei-prj\taobei-dev\imgs\19.png>加入购物车</button>
                                <button class="btn btn-default add-to-favorites" data-name="遮阳膜" data-price="9.8" data-image=D:\taobei-prj\taobei-dev\imgs\19.png>收藏</button>
                            </p>
                        </div>
                    </div>
                    <div class="thumbnail">
                        <img src=D:\taobei-prj\taobei-dev\imgs\20.png alt="隐形车衣贴膜">
                        <div class="caption">
                            <h3>隐形车衣贴膜</h3>
                            <p>隐形车衣贴膜汽车膜全车漆面保护膜tpu透明磨砂哑光亮黑武士直销</p>
                            <p>价格:2980</p>
                            <p>
                                <button class="btn btn-default add-to-cart" data-name="隐形车衣贴膜" data-price="2980" data-image=D:\taobei-prj\taobei-dev\imgs\20.png>加入购物车</button>
                                <button class="btn btn-default add-to-favorites" data-name="隐形车衣贴膜" data-price="2980" data-image=D:\taobei-prj\taobei-dev\imgs\20.png>收藏</button>
                            </p>
                        </div>
                    </div>
                    <div class="thumbnail">
                        <img src=D:\taobei-prj\taobei-dev\imgs\21.png alt="车用清洗剂">
                        <div class="caption">
                            <h3>车用清洗剂</h3>
                            <p>德国HB汽车真皮座椅清洗剂内饰皮革免水洗强力去污翻新车内清洁剂</p>
                            <p>价格:59</p>
                            <p>
                                <button class="btn btn-default add-to-cart" data-name="车用清洗剂" data-price="59" data-image=D:\taobei-prj\taobei-dev\imgs\21.png>加入购物车</button>
                                <button class="btn btn-default add-to-favorites" data-name="车用清洗剂" data-price="59" data-image=D:\taobei-prj\taobei-dev\imgs\21.png>收藏</button>
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <a href="../index.html" class="btn btn-link">返回主页</a>
    </div>

    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    <script>
        // 加入购物车功能
        document.addEventListener('DOMContentLoaded', function () {
            const addToCartButtons = document.querySelectorAll('.add-to-cart');
            addToCartButtons.forEach(button => {
                button.addEventListener('click', function () {
                    const product = {
                        name: button.getAttribute('data-name'),
                        price: button.getAttribute('data-price'),
                        image: button.getAttribute('data-image')
                    };
                    addToCart(product);
                });
            });

            // 收藏功能
            const addToFavoritesButtons = document.querySelectorAll('.add-to-favorites');
            addToFavoritesButtons.forEach(button => {
                button.addEventListener('click', function () {
                    const product = {
                        name: button.getAttribute('data-name'),
                        price: button.getAttribute('data-price'),
                        image: button.getAttribute('data-image')
                    };
                    addToFavorites(product);
                });
            });

            function addToCart(product) {
                let cart = JSON.parse(localStorage.getItem('cart')) || [];
                cart.push(product);
                localStorage.setItem('cart', JSON.stringify(cart));
                alert('商品已加入购物车！');
            }

            function addToFavorites(product) {
                let favorites = JSON.parse(localStorage.getItem('favorites')) || [];
                favorites.push(product);
                localStorage.setItem('favorites', JSON.stringify(favorites));
                alert('商品已收藏！');
            }
        });
    </script>
</body>
</html>